﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace FBNotifier
{
    /// <summary>
    /// Interaction logic for OptionsWindow.xaml
    /// </summary>
    public partial class OptionsWindow : Window
    {
        public static bool OptionWindowOpened = false;

        public OptionsWindow()
        {
            OptionWindowOpened = true;
            InitializeComponent();
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            (Application.Current as App).RefreshTime = Convert.ToInt32(slider1.Value);
            (Application.Current as App).AutoStartWithWindows = checkBoxStartType.IsChecked == true;
            (Application.Current as App).AnimationType = (App.AnimationTypes)animationCombo.SelectedIndex;
            (Application.Current as App).PlaySounds = checkBoxPlaySounds.IsChecked == true;

            Close();
        }

        private void slider1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            currentTime.Content = (int)e.NewValue + " sec";
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            slider1.ValueChanged += slider1_ValueChanged;

            slider1.Minimum = 20;
            slider1.Maximum = 200;

            slider1.Value = (Application.Current as App).RefreshTime;

            checkBoxStartType.IsChecked = (Application.Current as App).AutoStartWithWindows;
            checkBoxPlaySounds.IsChecked = (Application.Current as App).PlaySounds;

            animationCombo.SelectedIndex = (int)(Application.Current as App).AnimationType;
        }

        private void Window_Closed(object sender, EventArgs e)
        {
            OptionWindowOpened =  false;
        }
    }
}
